package com.code;

/**
 * 根据数值 从后往前交换
 * Created by lucky on 2018/9/27.
 */
public class Code7 {
    public static void main(String[] args) {
        int[] potate = new int[]{-1,-100,3,99};
        rotate(potate,2);
        for (int i = 0 ; i< potate.length ; i++){
            System.out.print(potate[i] + ",");
        }
    }

    public static void rotate(int[] nums, int k) {
        for (int j = 0 ; j < k ; j++){
            int temp = nums[nums.length-1];
            for (int i = nums.length -1 ; i > 0 ; i--){
                nums[i] = nums[i-1];
            }
            nums[0] = temp;
        }
    }
}
